from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModStationWeeklyRep import StationWeeklyRep, stationWeeklyRepSchema
from database import Session, engine
import datetime
from sqlalchemy import Date, DateTime


def get_weeklyrep_info(session, bureauid: str, monthnum: Date, weeknum: int):
    # 根据县局，月份查询供电所指标排名周报
    weeklyrep_info = session.query(StationWeeklyRep).filter(StationWeeklyRep.bureauid == bureauid).filter(
        StationWeeklyRep.monthnum == monthnum).filter(StationWeeklyRep.weeknum == weeknum).order_by(
        StationWeeklyRep.stationid.asc()).all()
    return JSONResponse(stationWeeklyRepSchema.dump(weeklyrep_info, many=True).data)
